<template>
    <div class="login">
        <form>
            <div>
                <label for="username">用户名：</label>
                <input type="text" v-model="loginForm.username" />
            </div>

            <div>
                <label for="password">密码：</label>
                <input type="password" v-model="loginForm.password" />
            </div>

            <button @click.prevent="login">登录</button>
        </form>
    </div>
</template>

<script>
export default {
    data() {
        return {
            loginForm: {
                username: '',
                password: '',
            },
        };
    },
    methods: {
        async login() {
            console.log(this.loginForm);
            const res = await this.$http.post(
                '/api/users/login',
                this.loginForm,
            );
            console.log(res);
        },
    },
};
</script>
